//
//  XMMineHomeCell.m
//  XMJJ_zml
//
//  Created by apple on 2025/5/10.
//

#import "XMMineHomeCell.h"

@interface XMMineHomeCell ()

@property (nonatomic, strong) UIImageView *headImgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *likeBtn;

@end

@implementation XMMineHomeCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    UIView *contentView = [[UIView alloc] initWithFrame:self.bounds];
    contentView.backgroundColor = kColorHEX(0xffffff);
    [contentView setCornerRadius:KScaleWidth(8.0)];
    [self addSubview:contentView];
    [contentView addSubview:self.headImgView];
    [contentView addSubview:self.titleLabel];
    [contentView addSubview:self.likeBtn];
}

- (void)likeAction:(UIButton *)button {
    
}

- (void)setContentWithProduction:(XMProductModel *)productModel {
//    _headImgView.image = [UIImage imageWithColor:kColorHEX(0x00ffff)];
    [_headImgView sd_setImageWithURL:[NSURL URLWithString:productModel.coverImageUrl]];
    _titleLabel.text = productModel.title;//@"芝麻盐儿";
}

#pragma mark - Init
- (UIImageView *)headImgView {
    if (!_headImgView) {
        _headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, KScaleWidth(128.0))];
    }
    return _headImgView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScaleWidth(8.0), self.height - KScaleWidth(28.0), self.width - KScaleWidth(8.0) - KScaleWidth(25.0), KScaleWidth(28.0)) font:KFontSize(13.0) textColor:kColorHEX(0x333333)];
    }
    return _titleLabel;
}

- (UIButton *)likeBtn {
    if (!_likeBtn) {
        _likeBtn = [UIButton buttonWithType:UIButtonTypeCustom frame:CGRectMake(self.width - KScaleWidth(4.0) - KScaleWidth(23.0), self.height - KScaleWidth(28.0), KScaleWidth(23.0), KScaleWidth(28.0)) image:@"mine_product_like_icon" selectImg:@"mine_product_like_icon_select"];
        [_likeBtn addTarget:self action:@selector(likeAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _likeBtn;
}

@end
